﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BITUI.nes
{
    internal class Controller : MyNes.Core.IJoypadConnecter
    {
        public bool bLeft;
        public bool bUp;
        public bool bRight;
        public bool bDown;
        public bool bBtnA;
        public bool bBtnB;
        public bool bBtnSelect;
        public bool bBtnStart;
        public override void Update()
        {
            var tagright = (bRight ? 1 : 0) << 7; //right
            var tagleft = (bLeft ? 1 : 0) << 6;//left
            var tagdown = (bDown ? 1 : 0) << 5;
            var tagup = (bUp ? 1 : 0) << 4;
            var tagStart = (bBtnStart ? 1 : 0) << 3; //sure
            var tagSel = (bBtnSelect ? 1 : 0) << 2;
            var tagB = (bBtnB ? 1 : 0) << 1;
            var tagA = (bBtnA ? 1 : 0) << 0;
            this.DATA = (byte)(tagleft | tagup | tagdown | tagright | tagA | tagB | tagSel | tagStart);
        }
    }
}
